package org.learn.java.observ;

import java.util.Observable;

public class Change extends Observable{

	private Long id;
	private String name;
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
		//修改内部标识
		setChanged();
		//通知观察者
		//notifyObservers();
	}
	
	/**
	 * 重写方法，将修改内部标识和通知观察者放在一起
	 */
	protected synchronized void setChanged() {
		super.setChanged();
		notifyObservers();
    }
}
